const tools = {
    methods: {
        fill0(num) {
            return num < 10 ? '0' + num : num
        },
        //通过字母拿到索引
        getLetterBindexyIndex(index) {
            return String.fromCharCode("A".charCodeAt(0) + index);
        },
        getScore(qArr) {
            const scorePerQuestion = 100 / qArr.length
            let score = qArr.reduce(function (total, obj) {
                if (obj.userAnswers && (obj.userAnswers == obj.answers)) {
                    return total + scorePerQuestion
                } else {
                    return total
                }
            }, 0)
            return score
        }
    },
}

export default tools